#include "..\headers\ListOf.h"

#define MAX_SIZE 100

int main() {
  char stack[MAX_SIZE];
  int top = -1;
  char ch;

  printf("Enter a line of text: ");
  while ((ch = getchar()) != '\n' && top < MAX_SIZE - 1) {
    switch (ch) {
      case '#':  // If the character is '#', decrement the top pointer
        if (top != -1) {
          --top;
        }
        break;
      case '@':  // If the character is '@', reset the top pointer
        top = -1;
        break;
      default:  // If the character is not '#' or '@', push it to the stack
        stack[++top] = ch;
        break;
    }
  }

  // Print the remaining characters in the stack
  printf("The final text is: ");
  for (int i = 0; i <= top; ++i) {
    putchar(stack[i]);
  }
  printf("\n");

  return 0;
}